<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Teacher filter form base class.
 *
 * @package    elearning
 * @subpackage filter
 * @author     Your name here
 */
class BaseTeacherFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'country_id'           => new sfWidgetFormPropelChoice(array('model' => 'Country', 'add_empty' => true)),
      'degree_id'            => new sfWidgetFormPropelChoice(array('model' => 'Degree', 'add_empty' => true)),
      'teacher_account_name' => new sfWidgetFormFilterInput(),
      'teacher_password'     => new sfWidgetFormFilterInput(),
      'teacher_first_name'   => new sfWidgetFormFilterInput(),
      'teacher_last_name'    => new sfWidgetFormFilterInput(),
      'birthday'             => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'teacher_about_me'     => new sfWidgetFormFilterInput(),
      'teacher_education'    => new sfWidgetFormFilterInput(),
      'teacher_experience'   => new sfWidgetFormFilterInput(),
      'teacher_addresss'     => new sfWidgetFormFilterInput(),
      'teacher_phone'        => new sfWidgetFormFilterInput(),
      'teacher_email'        => new sfWidgetFormFilterInput(),
      'teacher_avatar_img'   => new sfWidgetFormFilterInput(),
      'teacher_last_visit'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'created_at'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'country_id'           => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Country', 'column' => 'iso')),
      'degree_id'            => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Degree', 'column' => 'id')),
      'teacher_account_name' => new sfValidatorPass(array('required' => false)),
      'teacher_password'     => new sfValidatorPass(array('required' => false)),
      'teacher_first_name'   => new sfValidatorPass(array('required' => false)),
      'teacher_last_name'    => new sfValidatorPass(array('required' => false)),
      'birthday'             => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'teacher_about_me'     => new sfValidatorPass(array('required' => false)),
      'teacher_education'    => new sfValidatorPass(array('required' => false)),
      'teacher_experience'   => new sfValidatorPass(array('required' => false)),
      'teacher_addresss'     => new sfValidatorPass(array('required' => false)),
      'teacher_phone'        => new sfValidatorPass(array('required' => false)),
      'teacher_email'        => new sfValidatorPass(array('required' => false)),
      'teacher_avatar_img'   => new sfValidatorPass(array('required' => false)),
      'teacher_last_visit'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'created_at'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('teacher_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Teacher';
  }

  public function getFields()
  {
    return array(
      'id'                   => 'Number',
      'country_id'           => 'ForeignKey',
      'degree_id'            => 'ForeignKey',
      'teacher_account_name' => 'Text',
      'teacher_password'     => 'Text',
      'teacher_first_name'   => 'Text',
      'teacher_last_name'    => 'Text',
      'birthday'             => 'Date',
      'teacher_about_me'     => 'Text',
      'teacher_education'    => 'Text',
      'teacher_experience'   => 'Text',
      'teacher_addresss'     => 'Text',
      'teacher_phone'        => 'Text',
      'teacher_email'        => 'Text',
      'teacher_avatar_img'   => 'Text',
      'teacher_last_visit'   => 'Date',
      'created_at'           => 'Date',
      'updated_at'           => 'Date',
    );
  }
}
